package InternetServices;


import java.util.Map;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.MarshalBase64;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;

public class WebServiceCall {
	
	private String NAMESPACE = "http://tempuri.org/";
	private String URL = "http://demo.sagarinfotech.com/json/PodEntryService.asmx";
	private String SOAP_ACTION = "http://tempuri.org/";
	private String JSONResponse = "";

	public String webServiceMethod(String methodName,Map<String, String> map) {
		try {
			SoapObject request = new SoapObject(NAMESPACE, methodName);
			SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
					SoapEnvelope.VER11);
			envelope.dotNet = true;
			if (map.size() != 0) {
				for (Map.Entry<String, String> entry : map.entrySet()) {
					request.addProperty(entry.getKey(), entry.getValue());
				}
			}
			new MarshalBase64().register(envelope);
			envelope.setOutputSoapObject(request);
			HttpTransportSE androidTransportCall = new HttpTransportSE(URL);
			try {
				androidTransportCall.call(SOAP_ACTION + methodName, envelope);
				SoapPrimitive responsePrimitive = (SoapPrimitive) envelope
						.getResponse();
				JSONResponse = responsePrimitive.toString();
			} catch (Exception e) {
				e.printStackTrace();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return JSONResponse;
	}
}
